667A - Pouring Rain - CodeForces Solution


geometry math *1100

Please click on ads to support us..

Python Code:

from math import pi

cup_diameter, initial_water_height, drinking_speed_in_ml_per_sec, growth_water_speed_in_cm_per_sec = map(int, input().split())

cup_radius = cup_diameter / 2

growth_water_speed_in_ml_per_sec = pi * cup_radius ** 2 * growth_water_speed_in_cm_per_sec

if growth_water_speed_in_ml_per_sec >= drinking_speed_in_ml_per_sec:
    print("NO")
else:
    speed_of_water_dicrease = drinking_speed_in_ml_per_sec - growth_water_speed_in_ml_per_sec
    initial_water_volume = pi * cup_radius ** 2 * initial_water_height

    print("YES")
    print(initial_water_volume / speed_of_water_dicrease)

C++ Code:

// Problem: A. Pouring Rain
// Contest: Codeforces - Codeforces Round #349 (Div. 2)
// URL: https://codeforces.com/contest/667/problem/A
// Memory Limit: 256 MB
// Time Limit: 1000 ms

/* 
     
     #WTFyouhere
                    ♕ABHINAV♕
     
        HUSTLE KARO BHASAD NHI..... 
          
                             
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
const unsigned int M = 1000000007;
//►►►►►►►►►►►►►►►►►►►►(⊙⊙)(☉_☉)(⊙⊙)►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►
ll power(ll a, ll b, ll m = M) {a %= m;ll res = 1;while (b > 0) {
if (b & 1)res = res * a % m;a = a * a % m;b >>= 1;}return res;}
ll gcd(ll x, ll y) {return (x ? gcd(y % x, x) : y);}
ll inv(ll n, ll m = M) {return power(n, m - 2, m);}
ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
ll nextgreaterelement(ll n) {auto digits = to_string(n);
next_permutation(begin(digits), end(digits));auto res = stoll(digits);return res;}
vector<int> factorize(int n) {vector<int> ans;for (int i = 2; i * i <= n; ++i) {
while (n % i == 0) {ans.push_back(i);n /= i;}}if (n != 1) {ans.push_back(n);}
for(int i=0;i<ans.size();i++)cout<<ans[i]<<" ";}
ll near_pow(ll q){ll ans = (ll)log2(q);return pow(2,ans);}
long long ceil(long long p, long long q) {if(p % q == 0) return (p / q);return (p / q) + 1;}
//►►►►►►►►►►►►►►►►►►►(⊙⊙)(☉_☉)(⊙⊙)►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►


void reply()
{
    ll t;
    cin>>t;
    while(t--)
    {
                        
                              
    }
    
}


int main() {
	// your code goes here
	//reply();
	double d,h,v,e;
    cin>>d>>h>>v>>e;
    double pi=3.14159265356;
    double tmp;
    double r=d/2;
    double s=pi*r*r;
    tmp=v/s;
    double res=e-tmp;
    if(res>0) cout << "NO" << endl;
    else
    { cout << "YES"<<endl;
    cout<<fixed<<setprecision(15)<<-h/res<<endl;
    }
	
	
	
}


Comments

Submit
0 Comments
More Questions

1630D - Flipping Range
1328A - Divisibility Problem
339A - Helpful Maths
4A - Watermelon
476A - Dreamoon and Stairs
1409A - Yet Another Two Integers Problem
977A - Wrong Subtraction
263A - Beautiful Matrix
180C - Letter
151A - Soft Drinking
1352A - Sum of Round Numbers
281A - Word Capitalization
1646A - Square Counting
266A - Stones on the Table
61A - Ultra-Fast Mathematician
148A - Insomnia cure
1650A - Deletions of Two Adjacent Letters
1512A - Spy Detected
282A - Bit++
69A - Young Physicist
1651A - Playoff
734A - Anton and Danik
1300B - Assigning to Classes
1647A - Madoka and Math Dad
710A - King Moves
1131A - Sea Battle
118A - String Task
236A - Boy or Girl
271A - Beautiful Year
520B - Two Buttons